<template>
  <div>
    <van-nav-bar left-text="返回" left-arrow @click-left="onClickLeft" />
    <van-divider />
    <van-cell-group>
      <van-field v-model="value" label="标题" placeholder="请输入新标题" />
    </van-cell-group>
    <van-button class="btn" @click="rewrite" plain size="small" type="info">保存修改</van-button>
  </div>
</template>
<script>
import { rewriteCard } from "../../api/forum-api";
import {Toast} from 'vant'
export default {
  data() {
    return {
      value: "",
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    // 修改帖子
    rewrite() {
      rewriteCard(this.$route.params.postsId, this.value).then(res => {
        // console.log(res);
        Toast.success('修改成功');
        this.$router.go(-1);
      });
    }
  }
};
</script>
<style lang="less" scoped>
.btn {
  margin-top: 20px;
  float: right;
  margin-right: 20px;
}
</style>